package com.cecsmsserve.mapper;

import com.cecsmsserve.entity.Activity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;

import java.util.HashMap;
import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 王郝浠
 * @since 2024-04-17
 */
public interface ActivityMapper extends BaseMapper<Activity> {

    @ResultMap("activityMap")
    @Select("select * from activity")
    List<Activity> selectAll();

    @ResultMap("activityMap")
    @Select("select * from activity where state=#{state}")
    List<Activity> selectByState(int state);
    
    @ResultMap("activityMap")
    @Select("select * from activity where activityTypeId=#{activityTypeId}")
    List<Activity> selectByType(int activityTypeId);

    @ResultMap("activityMap")
    @Select("select * from activity order by activityDate desc limit #{arg0},#{arg1}")
    List<Activity> selectAllByPage(int start, int size);

    @ResultMap("activityMap")
    @Select("select * from activity where state!=0 order by activityDate desc limit 5")
    List<Activity> selectNotBegin();

    @ResultMap("activityMap")
    @Select("select * from activity where activityName like concat('%',#{name},'%')")
    List<Activity> selectByName(String name);

    @ResultMap("activityMap")
    @Select("select * from activity where activityName like concat('%',#{arg0},'%') order by activityDate desc limit #{arg1},#{arg2}")
    List<Activity> selectByNameByPage(String name,int start, int size);

    @ResultMap("activityMap")
    @Select("select * from activity where id=#{id}")
    Activity selectById(int id);

    List<HashMap<String, Object>> countSignedUpNum();

    List<HashMap<String, Object>> countActivitySort();
}
